import Vue from "vue";
import VueRouter from "vue-router";
import HomePage from "@/views/HomePage";
import UserPage from "@/views/UserPage";
import MainPage from "@/views/MainPage";
import MallPage from "@/views/MallPage";
import PageOne from "@/views/PageOne";
import PageTwo from "@/views/PageTwo";

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        component: MainPage,
        redirect: '/home',
        children: [
            {path: 'home', component: HomePage},
            {path: 'user', component: UserPage},
            {path: 'mall', component: MallPage},
            {path: 'page1', component: PageOne},
            {path: 'page2', component: PageTwo},
        ]
    },
]

const router = new VueRouter({
    routes
})

const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

export default router